package service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pojo.Food;
import service.FoodManager;
import dao.FoodDao;

@Service(value="foodManager")
public class FoodManagerImpl implements FoodManager{
	@Resource(name="foodDao")
	private FoodDao foodDao;

	@Override
	public List<Food> findByType(String typeId, String m_id) {
		if("all".equals(typeId)){
			return foodDao.findAll(m_id);
		}
		else{
			return foodDao.findByType(typeId, m_id);
		}
	}

	@Override
	public List<Food> findAll() {
		return foodDao.findAll("8a5e9d2c5de386a5015de3a66b400002");
	}

	@Override
	@Transactional
	public void addFood(Food food, String m_id, String c_id) {
//    	Food food1 = new Food(null, "jordan_food_nimei", 12, "test_image");
//
//    	String m_idString = "8a5e9d1a5dda332f015dda3333990000";
//    	String c_idString = "8a5e9d1a5dda2f75015dda2f78d60000";
    	
    	foodDao.addFood(food, m_id, c_id);
	}

}
